Skip to content

Conversation

@lopopolo-openai
Copy link

@lopopolo-openai lopopolo-openai commented Jan 24, 2026

Summary

This PR adds regression test coverage only for a directory_tree structured-content validation bug that appears to have already been fixed upstream.

There are no runtime behavior changes in this PR.

Context

The -32602 error reported in:

occurs when a tool declares outputSchema: { content: string } but returns structuredContent.content as an array.

From git history, this appears to have been fixed in:

Note: I opened this PR after seeing the open bug reports and reproducing the issue in an older build, but I did not initially confirm that main already contained the fix. I’m keeping this PR scoped to test coverage in case it’s still useful as a regression guard.

What this PR does

  • Adds src/filesystem/__tests__/directory-tree.mcp-sdk.test.ts
    • Uses @modelcontextprotocol/sdk + StdioClientTransport to call directory_tree end-to-end.
    • Asserts that structuredContent.content is a string and JSON-parseable.
  • Makes structured-content.test.ts slightly more robust on macOS by resolving the temp directory with fs.realpath() so the allowlist path matches /private/... temp paths.

This is intended to help prevent reintroducing the same outputSchema/structuredContent mismatch.

Minimal reproduction snippet (for older builds)

I was able to reproduce the -32602 validation error by running the filesystem server over stdio and calling directory_tree through the MCP SDK client.

Maintainers can run the following snippet directly (Node 20+):

import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
import fs from 'node:fs/promises';
import os from 'node:os';
import path from 'node:path';

const tmp = await fs.mkdtemp(path.join(os.tmpdir(), 'mcp-fs-tree-'));
const root = await fs.realpath(tmp);
await fs.writeFile(path.join(root, 'a.txt'), 'hello');

const transport = new StdioClientTransport({
  command: 'npx',
  args: ['-y', '@modelcontextprotocol/server-filesystem', root],
});

const client = new Client({ name: 'debug-client', version: '1.0.0' }, { capabilities: {} });
await client.connect(transport);

const result = await client.callTool({
  name: 'directory_tree',
  arguments: { path: root },
});

console.log(result.structuredContent);
await client.close();

On buggy builds, this call throws McpError: -32602 ... Expected string, received array at path: ["content"].

Release context

I have not traced the exact release tag for e6933ca, but based on timestamps it looks like the fix (2025-12-11) should be included in npm releases published after that date (for example @modelcontextprotocol/server-filesystem@2025.12.18 and later).

Happy to update this PR with the exact release tag if you'd like me to track it down precisely.

Test plan

  • npm test --workspace @modelcontextprotocol/server-filesystem

Follow-up suggestion (optional)

If you'd like, I can follow up with a small CI-level "functional" test job that runs a tiny MCP SDK client against the built dist/index.js binaries for select servers (filesystem, memory, etc.) to assert that schema validation passes for a few representative tool calls.

I didn't include CI changes in this PR since I wasn't sure how you'd want to scope cross-package functional tests.

Authorship note

This contribution (bug identification, repro, test updates, and PR drafting) was authored with OpenAI Codex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant